package io.github.jast90.internship.controller;

import io.github.jast90.internship.service.ExcelService;
import io.github.jast90.web.common.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * Created by jast90 on 2021/3/12
 */
@Controller
public class ExcelController {

    @Autowired
    private ExcelService excelService;

    @GetMapping("excel/user/template")
    public void exportUserTemplate(HttpServletResponse response) {
        excelService.exportUserTemplate(response);
    }

    @GetMapping("excel/weekly/export")
    public void weeklyExport(HttpServletResponse response) {
        excelService.exportAllInternshipWeekly(response);
    }

    @ResponseBody
    @PostMapping("excel/user/import")
    public CommonResult importUsers(@RequestParam("file") MultipartFile multipartFile){
        return excelService.uploadUsers(multipartFile);
    }
}
